vtd: Disable VT-d if no DRHD units are probed.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 19 Oct 2009 15:50:14 +0000 (16:50 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 19 Oct 2009 15:50:14 +0000 (16:50 +0100)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/drivers/passthrough/iommu.c
xen/drivers/passthrough/vtd/iommu.c

index b1ce67f7415a4e0c9b6975fe5a80b4171c4a19d4..cfa74f9579ae9d4992c9ac88b804104d8b19fc2b 100644 (file)
@@ -266,9 +266,11 @@ int iommu_setup(void)
 {
     int rc = -ENODEV;
 
-    rc = iommu_hardware_setup();
-
-    iommu_enabled = (rc == 0);
+    if ( iommu_enabled )
+    {
+        rc = iommu_hardware_setup();
+        iommu_enabled = (rc == 0);
+    }
 
     if ( force_iommu && !iommu_enabled )
         panic("IOMMU setup failed, crash Xen for security purpose!\n");
index ddf1543fbc088db3a25288b849cd8fdbd10f6d23..4d5702e7293535b26ac2847f10c26b48ad61778d 100644 (file)
@@ -1707,7 +1707,7 @@ int intel_vtd_setup(void)
     struct acpi_drhd_unit *drhd;
     struct iommu *iommu;
 
-    if ( !iommu_enabled )
+    if ( list_empty(&acpi_drhd_units) )
         return -ENODEV;
 
     platform_quirks();
@@ -1760,18 +1760,15 @@ int intel_vtd_setup(void)
     P(iommu_intremap, "Interrupt Remapping");
 #undef P
 
+    /* Allocate domain id bitmap, and set bit 0 as reserved. */
     drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list);
-    if ( drhd != NULL )
-    {
-        /* Allocate domain id bitmap, and set bit 0 as reserved. */
-        domid_bitmap_size = cap_ndoms(drhd->iommu->cap);
-        domid_bitmap = xmalloc_array(unsigned long,
-                                     BITS_TO_LONGS(domid_bitmap_size));
-        if ( domid_bitmap == NULL )
-            goto error;
-        memset(domid_bitmap, 0, domid_bitmap_size / 8);
-        __set_bit(0, domid_bitmap);
-    }
+    domid_bitmap_size = cap_ndoms(drhd->iommu->cap);
+    domid_bitmap = xmalloc_array(unsigned long,
+                                 BITS_TO_LONGS(domid_bitmap_size));
+    if ( domid_bitmap == NULL )
+        goto error;
+    memset(domid_bitmap, 0, domid_bitmap_size / 8);
+    __set_bit(0, domid_bitmap);
 
     scan_pci_devices();